/*
 * @lc app=leetcode.cn id=884 lang=typescript
 *
 * [884] 两句话中的不常见单词
 */

// @lc code=start
function uncommonFromSentences(s1: string, s2: string): string[] {
    let common = new Set<string>();
    let result = new Set<string>();
    const stringToArr = (s: string) => {
        s.split(" ").forEach((i) => {
            if (common.has(i)) return;
            if (result.has(i)) {
                result.delete(i);
                common.add(i);
            } else {
                result.add(i);
            }
        });
    };

    stringToArr(s1);
    stringToArr(s2);
    return [...result];
}

// @lc code=end
